package com.authorization.project.single.controller;

import java.util.List;

import com.authorization.project.single.domain.SingleAuthorizationServiceMapping;
import com.authorization.project.single.service.ISingleAuthorizationServiceMappingService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.authorization.framework.aspectj.lang.annotation.Log;
import com.authorization.framework.aspectj.lang.enums.BusinessType;
import com.authorization.framework.web.controller.BaseController;
import com.authorization.framework.web.domain.AjaxResult;
import com.authorization.common.utils.poi.ExcelUtil;
import com.authorization.framework.web.page.TableDataInfo;

/**
 * 单服务授权信息-服务中间Controller
 * 
 * @author 李晓雷
 * @date 2020-07-11
 */
@RestController
@RequestMapping("/system/mapping")
public class SingleAuthorizationServiceMappingController extends BaseController
{
    @Autowired
    private ISingleAuthorizationServiceMappingService singleAuthorizationServiceMappingService;

    /**
     * 查询单服务授权信息-服务中间列表
     */
    @PreAuthorize("@ss.hasPermi('system:mapping:list')")
    @GetMapping("/list")
    public TableDataInfo list(SingleAuthorizationServiceMapping singleAuthorizationServiceMapping)
    {
        startPage();
        List<SingleAuthorizationServiceMapping> list = singleAuthorizationServiceMappingService.selectSingleAuthorizationServiceMappingList(singleAuthorizationServiceMapping);
        return getDataTable(list);
    }

    /**
     * 导出单服务授权信息-服务中间列表
     */
    @PreAuthorize("@ss.hasPermi('system:mapping:export')")
    @Log(title = "单服务授权信息-服务中间", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SingleAuthorizationServiceMapping singleAuthorizationServiceMapping)
    {
        List<SingleAuthorizationServiceMapping> list = singleAuthorizationServiceMappingService.selectSingleAuthorizationServiceMappingList(singleAuthorizationServiceMapping);
        ExcelUtil<SingleAuthorizationServiceMapping> util = new ExcelUtil<SingleAuthorizationServiceMapping>(SingleAuthorizationServiceMapping.class);
        return util.exportExcel(list, "mapping");
    }

    /**
     * 获取单服务授权信息-服务中间详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:mapping:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(singleAuthorizationServiceMappingService.selectSingleAuthorizationServiceMappingById(id));
    }

    /**
     * 新增单服务授权信息-服务中间
     */
    @PreAuthorize("@ss.hasPermi('system:mapping:add')")
    @Log(title = "单服务授权信息-服务中间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SingleAuthorizationServiceMapping singleAuthorizationServiceMapping)
    {
        return toAjax(singleAuthorizationServiceMappingService.insertSingleAuthorizationServiceMapping(singleAuthorizationServiceMapping));
    }

    /**
     * 修改单服务授权信息-服务中间
     */
    @PreAuthorize("@ss.hasPermi('system:mapping:edit')")
    @Log(title = "单服务授权信息-服务中间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SingleAuthorizationServiceMapping singleAuthorizationServiceMapping)
    {
        return toAjax(singleAuthorizationServiceMappingService.updateSingleAuthorizationServiceMapping(singleAuthorizationServiceMapping));
    }

    /**
     * 删除单服务授权信息-服务中间
     */
    @PreAuthorize("@ss.hasPermi('system:mapping:remove')")
    @Log(title = "单服务授权信息-服务中间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(singleAuthorizationServiceMappingService.deleteSingleAuthorizationServiceMappingByIds(ids));
    }
}
